<?php include "menu.phtml"; ?>
<div id="right">
	<div class="rightbox">
		<div class="context"><div class="in"><a href="javascript:void(0);" id="context_menu" class="icon_link the_down"><span></span></a></div></div>
		<h1><?php echo $this->title; ?></h1>
		
	<table cellspacing="0" cellpadding="5" class="grid" width="800px" style="table-layout: fixed">
	<tr>
		<th><?php echo $this->translate->_("Name"); ?></th>
		<th><?php echo $this->translate->_("Email"); ?></th>
		<th><?php echo $this->translate->_("Address"); ?></th>
		<th><?php echo $this->translate->_("City"); ?></th>
		<th><?php echo $this->translate->_("Country"); ?></th>
		<th><?php echo $this->translate->_("Zipcode"); ?></th>
		<th><?php echo $this->translate->_("Type"); ?></th>
		<th><?php echo $this->translate->_("Edit"); ?></th>
		<th><?php echo $this->translate->_("Archive"); ?></th>
	</tr>
<?php
foreach ($this->users as $idx => $user):
    // avatar control
    $avatar = $this->partial('tickets/partials/avatar.phtml', array(
        'user' => $user
    ));
?>
	<tr>
		<td  style="word-break: break-all">
    		<a href="<?php echo $this->url(array('controller'=>'accounts', 'action'=>'view', 'user' => $user["id"]), 'default', true); ?>">
    		  <img src="<?php echo $avatar; ?>"
    			   style="display: block; padding: 3px; border: 1px solid #B3B3B3; background: white;"
    			   alt="<?php echo $this->translate->_("Profile Picture"); ?>" />
    		 </a>
	
	        <a href="<?php echo $this->url(array('controller'=>'accounts', 'action'=>'view', 'user' => $user["id"]), 'default', true); ?>">
					   <?php echo Petolio_Service_Util::escape($user["name"]); ?>
		    </a>
	    </td>
		<td style="word-break: break-all">
		   <?php echo Petolio_Service_Util::escape($user["email"]); ?>
		</td>
		<td style="word-break: break-all">
	       <?php echo Petolio_Service_Util::escape($user["address"]); ?>
		</td>
		<td style="word-break: break-all">
	       <?php echo Petolio_Service_Util::escape($user["location"]); ?>
		</td>
		<td style="word-break: break-all">
	       <?php echo Petolio_Service_Util::escape($this->country_list[$user["country_id"]]); ?>
	    </td>
		<td style="word-break: break-all">
	       <?php echo Petolio_Service_Util::escape($user["zipcode"]); ?>
		</td>
		<td style="word-break: break-all">
		  <?php 
		      if ( $user["type"] === 3 )
		      {
		          echo $this->translate->_("Non - Petolio");
		      }
		      else
		      {
		          echo $this->translate->_("Petolio");
		      }
		  ?>
	   </td>
	   <td style="word-break: break-all">
	       <a href="<?php echo $this->url(array(
	               'controller'=> 'tickets', 
	               'action'=> 'edit-client', 
	               'id' => $user["id"]
	       ), 'default', true); ?>">
	           <?php echo $this->translate->_("Edit"); ?>
	       </a>
		</td>
		<td style="word-break: break-all">
		  <form class="archive-form" method="POST" action="<?php echo $this->url(array('controller'=> 'tickets', 'action'=> 'archive-client'), 'default', true); ?>">
	           <input name="user_id" type="hidden" value="<?php echo $user["id"]; ?>" />
	           <input name="go" type="submit" value="X" />
	       </form>
		</td>
    </tr>
<?php endforeach; ?>
</table>
	</div>
</div>

<div id="archive-client-dialog-confirm" style="display: none" title="<?php echo $this->translate->_("Archive the client?") ?>">
  <?php echo $this->translate->_("The client will be archived. Are you sure?"); ?>
</div>

<script type="text/javascript" src="/js/ticket/myClients.js"></script>